#ifndef WIN32
#include "x11_selection.hpp"
#else
#include "win_clipboard.hpp"
#endif

#include <iostream>

itoken* clipboard::token = NULL;

clipboard::clipboard(itoken* _token)
{
	token = _token;	
   }

// just in case we do not want the whole token
clipboard::clipboard(itoken* _token, std::vector<unsigned short>& _idx)
{
	token = _token;	
	indices = _idx;
}


void clipboard::read_from(itoken* _token)
{
	clipboard* xsel =NULL;

#ifdef WIN32
	xsel = new windows_clipboard(_token);
#else
	xsel = new xsel_clipboard(_token);
#endif

	if(xsel != NULL)
	{
		xsel->read();		
	}
   }


void clipboard::read_from(itoken* _token, std::vector<unsigned short>& _idx)
{
	clipboard* xsel =NULL;

#ifdef WIN32
	xsel = new windows_clipboard(_token, _idx);
#else
	xsel = new xsel_clipboard(_token, _idx);
#endif
	
	if(xsel != NULL)
		xsel->read();
}


void clipboard::read()
{
	this->write_buffer();		
	delete this;
}


void clipboard::reset()	
{	
	clipboard* xsel =NULL;

#ifdef WIN32
	xsel = new windows_clipboard();
#else
	xsel = new xsel_clipboard();
#endif

	if(xsel != NULL)
	{
		xsel->clear_buffer();		
		delete xsel;
	}
}
